package com.gientech.redisDemo.redisController;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


import java.nio.charset.StandardCharsets;

@RestController
public class ProviderController {

    @GetMapping("test/01")
    public void syncMethod1() throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("producer");
        producer.setNamesrvAddr("172.0.0.1:9876");
        producer.start();
        for(int i =0;i<10;i++){
            Message message = new Message("Topmessage","Tag",("Hello RocketMq ["+i+" ]").getBytes(StandardCharsets.UTF_8));
            SendResult sendResult = producer.send(message);

        }
        producer.shutdown();
    }
}
